import FetchHelper from "./helper/fetch-helper";
import JSON5 from 'json5';

export default class Api {
    static getConfig() {
        return new Promise(resolve => {
            fetch(`${process.env.PUBLIC_URL}/config/app.json`).then(resp => {
                return resp.text()
            }).then(resp => {
                const r = JSON5.parse(resp)
                resolve(r)
            })
        })
        // return FetchHelper.getJson(`${process.env.PUBLIC_URL}/config/app.json5`);
    }
    static async getCztCategroy() {
        const cztCategroy = await FetchHelper.getJson(`${process.env.PUBLIC_URL}/datas/承灾体分类.json`)

        return cztCategroy;
    }
    static async getCztCategroy2() {
        const cztCategroy2 = await FetchHelper.getJson(`${process.env.PUBLIC_URL}/datas/承灾体分类_按键新增.json`)
        return cztCategroy2;
    }
    static async getCztByKey(key) {
        return {
            columns: [{
                name: 'mc',
                alias: '名称'
            }, {
                name: 'dz',
                alias: '地址'
            }],
            list: [{
                mc: '成功中学',
                dz: '四川省成都市郫都区'
            },
            {
                mc: '成功中学',
                dz: '四川省成都市郫都区'
            },
            {
                mc: '成功中学',
                dz: '四川省成都市郫都区'
            },
            ],
        }
    }
    //监测数据
    static async getJcsjCategroy() {
        const jcsjCategroy = await FetchHelper.getJson(`${process.env.PUBLIC_URL}/datas/监测数据信息.json`)
        return jcsjCategroy;
    }

    //减灾资源
    static async getJzzyCategroy() {
        const jzzyCategroy = await FetchHelper.getJson(`${process.env.PUBLIC_URL}/datas/减灾资源.json`)
        return jzzyCategroy;
    }
    static async getJzzyCategroy2() {
        const jzzyCategroy2 = await FetchHelper.getJson(`${process.env.PUBLIC_URL}/datas/减灾资源_按键新增.json`)
        return jzzyCategroy2;
    }

    static async getJzzyByKey(key) {
        return {
            columns: [{
                name: 'mc',
                alias: '名称'
            }, {
                name: 'dz',
                alias: '地址'
            }],
            list: [{
                mc: '四川省宜宾xx水利局',
                dz: '四川省宜宾市'
            },
            {
                mc: '四川省宜宾xx县xx建设局',
                dz: '四川省宜宾市'
            },
            {
                mc: '四川省宜宾xx气象局',
                dz: '四川省宜宾市'
            },
            ]
        }
    }
    //行政区划
    static async getXzqhCategroy() {
        const jzzyCategroy = await FetchHelper.getJson(`${process.env.PUBLIC_URL}/datas/减灾资源.json`)
        return jzzyCategroy;
    }

    //灾害风险
    static async getZhfxCategroy() {
        const zhfxCategroy = await FetchHelper.getJson(`${process.env.PUBLIC_URL}/datas/灾害风险.json`)
        return zhfxCategroy;
    }
    //重点防护目标
    static async getZdfhCategroy() {
        const zdfhCategroy = await FetchHelper.getJson(`${process.env.PUBLIC_URL}/datas/重点防护目标.json`)
        return zdfhCategroy;
    }
    //外部专家数据
    static async getWbzjsj() {
        const Wbzjsj = await FetchHelper.getJson(`${process.env.PUBLIC_URL}/datas/外部专家数据.json`)
        return Wbzjsj;
    }



}
